'use strict';

const _ = require('lodash');

authController.$inject = ['authService', '$location'];

function authController(authService, $location ) {

    let vm = this;

    vm.admin = {};

    vm.login = function(){
        if(_.isEmpty(vm.admin.password) || _.isEmpty(vm.admin.username)){
            vm.tipmsg = "username or password wrong!!";
        }else{
            authService.login(vm.admin).then(function (res) {
                console.log(res)
                if(null!=res.data){
                    $location.path("/unaudited");
                }else{
                    vm.tipmsg = "password wrong!!";
                }
            }).catch(err => console.log(err));
        }
    }

}
module.exports = authController;